<template>
  <div class="student-task-center">
    <div class="fullscreen-bg" aria-hidden="true"></div>
    <div class="page-header">
      <div class="header-left">
        <h2>学生任务中心</h2>
        <p class="subtitle"><span>欢迎，{{ studentDisplayName }}，</span>在这里查看和管理你的学习任务</p>
      </div>
      <div class="page-actions">
        <a-button danger @click="handleLogout">退出</a-button>
      </div>
    </div>
    
    <div class="task-filters">
      <div class="filter-group">
        <label>任务状态：</label>
        <a-select v-model:value="taskQuery.status" style="width: 200px" placeholder="全部" allowClear>
          <a-select-option value="">全部</a-select-option>
          <a-select-option value="pending">待完成</a-select-option>
          <a-select-option value="in-progress">进行中</a-select-option>
          <a-select-option value="completed">已完成</a-select-option>
        </a-select>
      </div>
      
      <div class="filter-group">
        <label>任务类型：</label>
        <a-select v-model:value="taskQuery.type" style="width: 200px" placeholder="全部" allowClear>
          <a-select-option value="">全部</a-select-option>
          <a-select-option value="coding">编程练习</a-select-option>
          <a-select-option value="quiz">知识测验</a-select-option>
          <a-select-option value="project">项目作业</a-select-option>
          <a-select-option value="reading">阅读任务</a-select-option>
        </a-select>
      </div>

      <div class="filter-group filter-search">
        <label>搜索：</label>
        <a-input v-model:value="taskQuery.title" placeholder="搜索任务标题或描述" />
      </div>

      <div class="filter-group filter-sort">
        <label>排序：</label>
        <a-select v-model:value="taskQuery.sortKey" style="width: 200px" placeholder="默认" allowClear>
          <a-select-option value="default">默认</a-select-option>
          <a-select-option value="deadline_asc">截止时间 ↑</a-select-option>
          <a-select-option value="deadline_desc">截止时间 ↓</a-select-option>
          <a-select-option value="difficulty">难度</a-select-option>
          <a-select-option value="estimatedTime">预计用时</a-select-option>
          <a-select-option value="status">状态</a-select-option>
        </a-select>
      </div>

      <div class="filter-actions">
        <a-button type="primary" @click="handleSearchTasks">查询</a-button>
        <a-button @click="handleResetTasks">重置</a-button>
        <a-button type="primary" @click="handleDemo()">Demo</a-button>
      </div>

      <div class="filter-stats">
        <span>共 {{ taskPagination.total }} 个任务</span>
        <span v-if="tasks.length > 0" class="stats-separator">|</span>
        <span v-if="tasks.length > 0">当前显示 {{ tasks.length }} 个</span>
      </div>
    </div>

    <!-- 加载状态 -->
    <div v-if="loading" class="loading-container">
      <a-spin size="large" />
      <p>正在加载任务...</p>
    </div>

    <!-- 任务列表 -->
    <div v-else-if="tasks.length" class="task-grid">
      <div 
        v-for="task in tasks" 
        :key="task.id || task.taskId || task.title"
        class="task-card"
        :class="getTaskStatusClass(task.status)"
      >
        <div class="task-header">
          <div class="task-type-badge" :class="task.type">
            {{ getTaskTypeLabel(task.type) }}
          </div>
          <div class="task-status-badge" :class="task.status">
            {{ getStatusLabel(task.status) }}
          </div>
        </div>
        
        <div class="task-content">
          <h3 class="task-title">{{ task.title }}</h3>
          <p class="task-description">{{ task.description }}</p>
          
          <div class="task-meta">
            <div class="meta-item">
              <span class="meta-label">截止时间：</span>
              <span class="meta-value">{{ formatDate(task.deadline) }}</span>
            </div>
            <div class="meta-item">
              <span class="meta-label">难度：</span>
              <span class="meta-value difficulty-{{ task.difficulty }}">
                {{ getDifficultyLabel(task.difficulty) }}
              </span>
            </div>
            <div class="meta-item">
              <span class="meta-label">预计用时：</span>
              <span class="meta-value">{{ task.estimatedTime }}分钟</span>
            </div>
          </div>

          <div class="task-progress">
            <ProgressBar
              :value="resolveProgress(task)"
              :color="resolveProgressColor(task)"
              :height="5"
              :show-label="true"
            />
          </div>
        </div>
        
        <div class="task-actions">
          <!-- 调试信息 -->
       
          
          <button 
            v-if="task.status === 'pending' || task.status === 'PENDING'" 
            class="btn btn-primary"
            @click="startTask(task.id || task.taskId)"
          >
            开始任务
          </button>
          <button 
            v-else-if="task.status === 'in-progress' || task.status === 'IN_PROGRESS' || task.status === 'in_progress'" 
            class="btn btn-continue"
            @click="continueTask(task.id || task.taskId)"
          >
            继续任务
          </button>
          <button 
            v-else-if="task.status === 'completed' || task.status === 'COMPLETED'" 
            class="btn btn-review"
            @click="reviewTask(task.id || task.taskId)"
          >
            查看结果
          </button>
          
          <!-- 默认按钮，当状态不匹配时显示 -->
          <button 
            v-else
            class="btn btn-primary"
            @click="startTask(task.id || task.taskId)"
          >
            开始任务
          </button>
        </div>
      </div>
    </div>

    <!-- 分页组件 -->
    <div v-if="tasks.length > 0" class="pagination-container">
   
      
      <a-pagination
        :current="taskPagination.pageNum"
        :pageSize="taskPagination.pageSize"
        :total="Math.max(taskPagination.total, tasks.length)"
        show-size-changer
        :page-size-options="['10','20','50']"
        @change="handleTaskPageChange"
        @showSizeChange="handleTaskPageSizeChange"
        show-total
        :show-total="(total, range) => `第 ${range[0]}-${range[1]} 条，共 ${total} 条`"
      />
    </div>
    
  
    <!-- 空状态 -->
    <div v-else-if="!loading && tasks.length === 0" class="no-tasks">
      <a-empty description="暂无符合条件的任务" />
    </div>
  </div>
</template>

<script setup>
import { ref, reactive, onMounted, watch, onUnmounted } from 'vue'
import { useRouter } from 'vue-router'
import ProgressBar from '../components/ProgressBar.vue'
import { getAuth } from '../utils/auth'
import { logout as doLogout } from '../utils/auth'
import { pageTasks, updateTaskApi } from '../api/task'
import { message } from 'ant-design-vue'

// 任务数据
const router = useRouter()
const tasks = ref([])
const loading = ref(false)
const taskPagination = reactive({
  pageNum: 1,
  pageSize: 10,
  total: 0
})

const taskQuery = reactive({
  status: '',
  type: '',
  title: '',
  sortKey: 'default'
})

// 防抖搜索
let searchTimer = null
const debouncedSearch = () => {
  if (searchTimer) {
    clearTimeout(searchTimer)
  }
  searchTimer = setTimeout(() => {
    handleSearchTasks()
  }, 500)
}

// 监听搜索输入变化
watch(() => taskQuery.title, () => {
  debouncedSearch()
})

// 监听其他筛选条件变化
watch([() => taskQuery.status, () => taskQuery.type, () => taskQuery.sortKey], () => {
  handleSearchTasks()
})

// 获取任务列表
const fetchTasks = async () => {
  loading.value = true
  try {
    const params = {
      pageNum: taskPagination.pageNum,
      pageSize: taskPagination.pageSize,
      ...taskQuery
    }
    
    // 移除空值参数
    Object.keys(params).forEach(key => {
      if (params[key] === '' || params[key] === 'default') {
        delete params[key]
      }
    })
    
    console.log('请求任务参数:', params)
    const data = await pageTasks(params)
    console.log('API返回数据:', data)
    console.log('API返回数据类型:', typeof data)
    console.log('API返回数据键:', data ? Object.keys(data) : 'null')
    
    if (data && data.records) {
      tasks.value = data.records
      taskPagination.total = data.total || 0
      console.log('设置任务数据:', tasks.value)
      console.log('设置分页总数:', taskPagination.total)
      console.log('任务状态示例:', tasks.value.map(t => ({ id: t.id, status: t.status, title: t.title })))
    } else if (data && Array.isArray(data)) {
      // 兼容直接返回数组的情况
      tasks.value = data
      taskPagination.total = data.length
      console.log('兼容模式: 直接返回数组，长度:', data.length)
    } else {
      tasks.value = []
      taskPagination.total = 0
      console.log('没有任务数据，data:', data)
    }
  } catch (error) {
    console.error('Error fetching tasks:', error)
    message.error('获取任务列表失败，请重试')
    tasks.value = []
    taskPagination.total = 0
  } finally {
    loading.value = false
  }
}

const handleDemo = async (taskId) => {
  console.log('开始任务:', taskId)
 // 跳转到完成任务页面
    router.push({ name: 'demo', params: { id: 1,taskId:'TASK001' } })
  
}

// 筛选与搜索、排序状态
const handleSearchTasks = () => {
  taskPagination.pageNum = 1
  fetchTasks()
}

const handleResetTasks = () => {
  Object.assign(taskQuery, {
    status: '',
    type: '',
    title: '',
    sortKey: 'default'
  })
  taskPagination.pageNum = 1
  fetchTasks()
}

const handleTaskPageChange = (page, pageSize) => {
  taskPagination.pageNum = page
  taskPagination.pageSize = pageSize
  fetchTasks()
}

const handleTaskPageSizeChange = (current, size) => {
  taskPagination.pageNum = 1
  taskPagination.pageSize = size
  fetchTasks()
}

// 获取任务类型标签
const getTaskTypeLabel = (type) => {
  const typeMap = {
    'coding': '编程',
    'CODING': '编程',
    'quiz': '测验',
    'QUIZ': '测验',
    'project': '项目',
    'PROJECT': '项目',
    'reading': '阅读',
    'READING': '阅读'
  }
  return typeMap[type] || type || '未知类型'
}

// 获取状态标签
const getStatusLabel = (status) => {
  const statusMap = {
    'pending': '待完成',
    'PENDING': '待完成',
    'in-progress': '进行中',
    'in_progress': '进行中',
    'IN_PROGRESS': '进行中',
    'completed': '已完成',
    'COMPLETED': '已完成'
  }
  return statusMap[status] || status || '未知状态'
}

// 获取难度标签
const getDifficultyLabel = (difficulty) => {
  const difficultyMap = {
    'easy': '简单',
    'EASY': '简单',
    'medium': '中等',
    'MEDIUM': '中等',
    'hard': '困难',
    'HARD': '困难'
  }
  return difficultyMap[difficulty] || difficulty || '未知难度'
}

// 格式化日期
const formatDate = (dateString) => {
  if (!dateString) return '未设置'
  try {
    const date = new Date(dateString)
    return date.toLocaleDateString('zh-CN')
  } catch (error) {
    return '日期格式错误'
  }
}

// 任务操作方法
const startTask = async (taskId) => {
  console.log('开始任务:', taskId)
  const current = tasks.value.find(t => t.id === taskId || t.taskId === taskId)
  console.log('找到的任务数据:', current)
  
  if (current) {
    // 确保任务数据包含必要的ID字段
    const taskData = {
      ...current,
      // 确保有id字段
      id: current.id || current.taskId || taskId,
      // 确保有taskId字段
      taskId: current.taskId || current.id || taskId
    }
    
    console.log('准备保存到localStorage的任务数据:', taskData)
    
    // 保存任务信息到本地存储
    localStorage.setItem('pp_current_task', JSON.stringify(taskData))
    console.log('任务已保存到localStorage')
    
    // 更新任务状态为进行中（如果当前是待完成状态）
    if (current.status === 'pending' || current.status === 'PENDING') {
      try {
        // 调用API更新任务状态
        await updateTaskApi(current.id || current.taskId, { status: 'in-progress' })
        console.log('任务状态已更新为进行中')
        
        // 更新本地任务状态
        current.status = 'in-progress'
        
        // 显示成功提示
        message.success('任务已开始，状态已更新')
      } catch (error) {
        console.error('更新任务状态失败:', error)
        message.warning('任务状态更新失败，但不影响进入任务页面')
      }
    }
    
    // 跳转到完成任务页面
    router.push({ name: 'do-task', params: { id: taskId } })
  } else {
    message.error('未找到任务信息，请刷新页面重试')
  }
}

const continueTask = async (taskId) => {
  console.log('继续任务:', taskId)
  const current = tasks.value.find(t => t.id === taskId || t.taskId === taskId)
  console.log('找到的任务数据:', current)
  
  if (current) {
    // 确保任务数据包含必要的ID字段
    const taskData = {
      ...current,
      // 确保有id字段
      id: current.id || current.taskId || taskId,
      // 确保有taskId字段
      taskId: current.taskId || current.id || taskId
    }
    
    console.log('准备保存到localStorage的任务数据:', taskData)
    
    // 保存任务信息到本地存储
    localStorage.setItem('pp_current_task', JSON.stringify(taskData))
    console.log('任务已保存到localStorage')
    
    // 跳转到完成任务页面
    router.push({ name: 'do-task', params: { id: taskId } })
  } else {
    message.error('未找到任务信息，请刷新页面重试')
  }
}

const reviewTask = (taskId) => {
  console.log('查看任务结果:', taskId)
  const current = tasks.value.find(t => t.id === taskId || t.taskId === taskId)
  console.log('找到的任务数据:', current)
  
  if (current) {
    // 确保任务数据包含必要的ID字段
    const taskData = {
      ...current,
      // 确保有id字段
      id: current.id || current.taskId || taskId,
      // 确保有taskId字段
      taskId: current.taskId || current.id || taskId
    }
    
    console.log('准备保存到localStorage的任务数据:', taskData)
    
    // 保存任务信息到本地存储
    localStorage.setItem('pp_current_task', JSON.stringify(taskData))
    console.log('任务已保存到localStorage')
    
    // 跳转到完成任务页面（只读模式）
    router.push({ name: 'do-task', params: { id: taskId } })
  } else {
    message.error('未找到任务信息，请刷新页面重试')
  }
}

// 进度条：不同状态的显示规则
const resolveProgress = (task) => {
  // 如果有明确的进度值，使用该值
  if (typeof task.progress === 'number') {
    return Math.max(0, Math.min(100, task.progress))
  }
  
  // 根据状态推断进度
  if (task.status === 'completed' || task.status === 'COMPLETED') {
    return 100
  }
  if (task.status === 'in-progress' || task.status === 'in_progress' || task.status === 'IN_PROGRESS') {
    return 50
  }
  if (task.status === 'pending' || task.status === 'PENDING') {
    return 0
  }
  
  // 默认进度
  return 0
}

const resolveProgressColor = (task) => {
  const status = task.status?.toLowerCase()
  switch (status) {
    case 'completed':
      return '#27ae60'
    case 'in-progress':
    case 'in_progress':
      return '#f39c12'
    case 'pending':
    default:
      return '#667eea'
  }
}

// 获取任务状态类名
const getTaskStatusClass = (status) => {
  const statusMap = {
    'pending': 'pending',
    'PENDING': 'pending',
    'in-progress': 'in-progress',
    'in_progress': 'in-progress',
    'IN_PROGRESS': 'in-progress',
    'completed': 'completed',
    'COMPLETED': 'completed',
    'default': 'default'
  }
  return statusMap[status] || 'default'
}

// 欢迎语
const studentDisplayName = (getAuth()?.username) || '同学'

// 退出
function handleLogout () {
  try { doLogout() } catch {}
  router.replace('/login')
}

// 页面加载时获取任务
onMounted(() => {
  console.log('页面加载，初始化分页数据:', taskPagination)
  // 确保分页数据正确初始化
  taskPagination.pageNum = 1
  taskPagination.pageSize = 10
  taskPagination.total = 0
  console.log('初始化后的分页数据:', taskPagination)
  fetchTasks()
  
  // 添加页面焦点事件监听，当从完成任务页面返回时自动刷新
  window.addEventListener('focus', handlePageFocus)
})

// 页面卸载时移除事件监听
onUnmounted(() => {
  window.removeEventListener('focus', handlePageFocus)
})

// 处理页面焦点事件
const handlePageFocus = () => {
  // 检查是否有任务状态变化，如果有则刷新列表
  const lastRefreshTime = localStorage.getItem('pp_last_task_refresh') || '0'
  const currentTime = Date.now()
  
  // 如果距离上次刷新超过5秒，则刷新任务列表
  if (currentTime - parseInt(lastRefreshTime) > 5000) {
    console.log('页面获得焦点，刷新任务列表')
    fetchTasks()
    localStorage.setItem('pp_last_task_refresh', currentTime.toString())
  }
}
</script>

<style scoped>
.student-task-center {
  max-width: 100%;
  margin: 0 auto;
  padding: 24px;
  /* min-height: 100vh; */
  position: relative;
  z-index: 1;
}

.fullscreen-bg {
  position: fixed;
  inset: 0;
  background: #e7e7e7;
  z-index: -1;
  pointer-events: none;
}

.page-header {
  text-align: left;
  margin-bottom: 40px;
  color: rgb(0, 0, 0);
  position: relative;
  z-index: 10;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
}

.page-header h1 {
  font-size: 3rem;
  color: rgb(0, 0, 0);
  margin-bottom: 16px;
  font-weight: 700;
  letter-spacing: -0.5px;
}
.welcome-text { color: #000000; opacity: 0.95; margin: 0 0 6px; font-weight: 500; }
.page-actions { margin-top: 4px; }

.subtitle {
  color: rgba(0, 0, 0, 0.9);
  margin: 0;
  font-weight: 300;
}

.task-filters {
  display: flex;
  gap: 24px;
  margin-bottom: 40px;
  padding: 24px;
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(10px);
  border-radius: 16px;
  flex-wrap: wrap;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.2);
  position: sticky;
  top: 10px;
  z-index: 5;
}

.filter-group {
  display: flex;
  align-items: center;
  gap: 8px;
}

.filter-group label {
  font-weight: 600;
  color: #2c3e50;
  white-space: nowrap;
  font-size: 0.95rem;
}

.filter-select {
  padding: 10px 16px;
  border: 2px solid #e1e5e9;
  border-radius: 8px;
  background: white;
  font-size: 14px;
  font-weight: 500;
  transition: all 0.2s ease;
  cursor: pointer;
}

.filter-select:focus {
  outline: none;
  border-color: #667eea;
  box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

/* 选择器尺寸对齐 */
.el-filter :deep(.ant-select),
.el-filter :deep(.ant-input) {
  min-width: 240px;
}

.filter-group .el-filter {
  width: 240px;
}

.el-filter :deep(.ant-select-selector) { min-height: 36px; }

.filter-search {
  flex: 1 1 240px;
}

.search-input {
  width: 100%;
  padding: 10px 14px;
  border: 2px solid #e1e5e9;
  border-radius: 8px;
  font-size: 14px;
  transition: all 0.2s ease;
}

.search-input:focus {
  outline: none;
  border-color: #764ba2;
  box-shadow: 0 0 0 3px rgba(118, 75, 162, 0.1);
}

.filter-sort {
  min-width: 200px;
}

.filter-actions {
  display: flex;
  gap: 12px;
  align-items: center;
}

.filter-actions .ant-btn {
  border-radius: 8px;
  font-weight: 500;
  transition: all 0.2s ease;
}

.filter-actions .ant-btn-primary {
  background: #667eea;
  border-color: #667eea;
  box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}

.filter-actions .ant-btn-primary:hover {
  background: #5a6fd8;
  border-color: #5a6fd8;
  box-shadow: 0 6px 16px rgba(102, 126, 234, 0.4);
}

.filter-actions .ant-btn:not(.ant-btn-primary) {
  border-color: #d9d9d9;
  color: #5a6c7d;
}

.filter-actions .ant-btn:not(.ant-btn-primary):hover {
  border-color: #667eea;
  color: #667eea;
}

.filter-stats {
  margin-left: auto;
  color: #2c3e50;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 8px;
}

.stats-separator {
  color: #d9d9d9;
  font-weight: 400;
}

.filter-stats span {
  font-size: 0.9rem;
}

.task-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 12px;
  margin-bottom: 30px;
  align-items: stretch;
}

.task-card {
  background: rgba(255, 255, 255, 0.96);
  border-radius: 10px;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.08);
  padding: 12px 10px 10px;
  border: 1px solid rgba(255, 255, 255, 0.35);
  position: relative;
  transition: transform .25s ease, box-shadow .25s ease;
  display: flex;
  flex-direction: column;
  height: 100%;
}

.task-card::before { display: none; }

.task-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.12);
}

.task-card.pending::before { display: none; }

.task-card.in-progress::before { display: none; }

.task-card.completed::before { display: none; }

.task-card.default::before { display: none; }

.task-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

.task-type-badge {
  padding: 3px 8px;
  border-radius: 14px;
  font-size: 9px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.2px;
  border: 1px solid transparent;
}

.task-type-badge.coding {
  background: rgba(52, 152, 219, 0.12);
  color: #3498db;
  border-color: rgba(52, 152, 219, 0.35);
}

.task-type-badge.quiz {
  background: rgba(155, 89, 182, 0.12);
  color: #9b59b6;
  border-color: rgba(155, 89, 182, 0.35);
}

.task-type-badge.project {
  background: rgba(230, 126, 34, 0.12);
  color: #e67e22;
  border-color: rgba(230, 126, 34, 0.35);
}

.task-type-badge.reading {
  background: rgba(26, 188, 156, 0.12);
  color: #1abc9c;
  border-color: rgba(26, 188, 156, 0.35);
}

.task-status-badge {
  padding: 3px 8px;
  border-radius: 14px;
  font-size: 9px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.2px;
  border: 1px solid transparent;
}

.task-status-badge.pending {
  background: rgba(231, 76, 60, 0.12);
  color: #e74c3c;
  border-color: rgba(231, 76, 60, 0.35);
}

.task-status-badge.in-progress {
  background: rgba(243, 156, 18, 0.12);
  color: #f39c12;
  border-color: rgba(243, 156, 18, 0.35);
}

.task-status-badge.completed {
  background: rgba(39, 174, 96, 0.12);
  color: #27ae60;
  border-color: rgba(39, 174, 96, 0.35);
}

.task-content { flex: 1 1 auto; }

.task-title {
  font-weight: 700;
  color: #2c3e50;
  font-size: 0.9rem;
  letter-spacing: 0.1px;
  margin: 0 0 5px 0;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.task-description {
  color: #5a6c7d;
  line-height: 1.4;
  margin-bottom: 12px;
  font-size: 0.8rem;
  font-weight: 400;
}

.task-meta {
  display: grid;
  gap: 5px 10px;
  background: #f3f5f7;
  padding: 8px;
  border-radius: 6px;
  font-size: 10px;
  margin-bottom: 8px;
}

.meta-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.meta-label {
  font-weight: 500;
  color: #34495e;
}

.meta-value {
  color: #2c3e50;
}

.difficulty-easy {
  color: #27ae60;
  font-weight: 500;
}

.difficulty-medium {
  color: #f39c12;
  font-weight: 500;
}

.difficulty-hard {
  color: #e74c3c;
  font-weight: 500;
}

.task-actions {
  padding: 0 10px 10px;
  margin-top: auto;
}

.btn {
  width: 100%;
  padding: 8px;
  border: none;
  border-radius: 5px;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: background-color 0.2s;
}

.btn-primary {
  background: #3498db;
  color: white;
}

.btn-primary:hover {
  background: #2980b9;
}

.btn-continue {
  background: #f39c12;
  color: white;
}

.btn-continue:hover {
  background: #e67e22;
}

.btn-review {
  background: #27ae60;
  color: white;
}

.btn-review:hover {
  background: #229954;
}

.no-tasks {
  text-align: center;
  padding: 40px;
  color: #7f8c8d;
  font-size: 1.1rem;
}

.loading-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px;
  background: rgba(255, 255, 255, 0.95);
  border-radius: 16px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
  margin: 20px 0;
}

.loading-container p {
  margin-top: 16px;
  color: #5a6c7d;
  font-size: 1rem;
  font-weight: 500;
}

.loading-container :deep(.ant-spin) {
  color: #667eea;
}

.loading-container :deep(.ant-spin-dot-item) {
  background-color: #667eea;
}

.pagination-container {
  display: flex;
  justify-content: center;
  margin-top: 30px;
}

/* 分页样式优化 */
.pagination-container :deep(.ant-pagination) {
  background: rgba(255, 255, 255, 0.95);
  padding: 16px 24px;
  border-radius: 12px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
}

.pagination-container :deep(.ant-pagination-total) {
  color: #5a6c7d;
  font-weight: 500;
}

.pagination-container :deep(.ant-pagination-item) {
  border-radius: 8px;
  border: 1px solid #d9d9d9;
  transition: all 0.2s ease;
}

.pagination-container :deep(.ant-pagination-item:hover) {
  border-color: #667eea;
  color: #667eea;
}

.pagination-container :deep(.ant-pagination-item-active) {
  background: #667eea;
  border-color: #667eea;
}

.pagination-container :deep(.ant-pagination-item-active a) {
  color: #fff;
}

.pagination-container :deep(.ant-pagination-options) {
  margin-left: 16px;
}

.pagination-container :deep(.ant-select) {
  border-radius: 8px;
}

.pagination-container :deep(.ant-pagination-options-quick-jumper) {
  margin-left: 16px;
}

.pagination-container :deep(.ant-pagination-options-quick-jumper input) {
  border-radius: 6px;
  border: 1px solid #d9d9d9;
  transition: border-color 0.2s ease;
}

.pagination-container :deep(.ant-pagination-options-quick-jumper input:focus) {
  border-color: #667eea;
  box-shadow: 0 0 0 2px rgba(102, 126, 234, 0.2);
}

@media (max-width: 768px) {
  .task-grid {
    grid-template-columns: 1fr;
  }
  
  .task-filters {
    flex-direction: column;
    gap: 15px;
  }
  
  .filter-group, .filter-search {
    width: 100%;
    flex: 1 1 100%;
  }

  .filter-group .el-filter {
    width: 100%;
  }

  .el-filter :deep(.ant-input),
  .el-filter :deep(.ant-select) {
    min-width: 100%;
  }
  
  .page-header h1 {
    font-size: 2rem;
  }
}

@media (min-width: 1200px) {
  .task-grid {
    grid-template-columns: repeat(7, 1fr);
  }
}

@media (min-width: 1000px) and (max-width: 1199px) {
  .task-grid {
    grid-template-columns: repeat(6, 1fr);
  }
}

@media (min-width: 800px) and (max-width: 999px) {
  .task-grid {
    grid-template-columns: repeat(5, 1fr);
  }
}

@media (min-width: 600px) and (max-width: 799px) {
  .task-grid {
    grid-template-columns: repeat(4, 1fr);
  }
}

@media (max-width: 599px) {
  .task-grid {
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
  }
  
  .task-card {
    padding: 10px 8px 8px;
  }
  
  .task-title {
    font-size: 0.85rem;
  }
  
  .task-description {
    font-size: 0.75rem;
    margin-bottom: 10px;
  }
  
  .task-meta {
    padding: 6px;
    font-size: 9px;
  }
  
  .btn {
    padding: 6px;
    font-size: 11px;
  }
}
</style> 